<?php
/**
 * +----------------------------------------------------------------------
 * | [ DO WHAT YOU LOVE AND FUCK THE REST ]
 * +----------------------------------------------------------------------
 * | EMAIL: < 931274989@qq.com >
 * +----------------------------------------------------------------------
 * | WECHAT: xzc016
 * +----------------------------------------------------------------------
 * | 基础控制器
 * +----------------------------------------------------------------------
 */
declare (strict_types = 1);

namespace app\admin\controller;

use think\exception\HttpResponseException;
use think\App;
use think\facade\Request;
use think\facade\Config;
use think\facade\View;

abstract class Base
{
  /**
   * Request实例
   * @var \think\Request
   */
  protected $request;

  /**
   * 应用实例
   * @var \think\App
   */
  protected $app;

  /**
   * 是否批量验证
   * @var bool
   */
  protected $batchValidate = false;

  /**
   * 控制器权限中间件
   * @var array
   */
  protected $middleware = [ 'app\admin\middleware\Permissions'];

  /**
   * 分页数量
   * @var string
   */
  protected $pageSize = '';

  /**
   * 构造方法
   * @access public
   * @param  App  $app  应用对象
   */
  public function __construct(App $app)
  {
    $this->app     = $app;
    $this->request = $this->app->request;

    // 控制器初始化
    $this->initialize();
  }

  // 初始化
  protected function initialize()
  {
    //每页显示数据量
    $this->pageSize = Request::param('page_size', Config::get('app.page_size'));

    //左侧菜单
    $menus = \app\admin\model\Base::getMenus();
    View::assign(['menus'=>$menus]);

    //pjax
    // if (Request::has('_pjax')) {
    //   View::assign(['pjax' => true]);
    // } else {
    //   View::assign(['pjax' => false]);
    // }

    // 面包导航
    // $auth = new \Auth();
    // $breadCrumb = $auth->getBreadCrumb();
    // $breadCrumb = format_bread_crumb($breadCrumb);
    // View::assign(['breadCrumb' => $breadCrumb]);

  }

}

?>